<template>
  用户名:<input type="text" v-model="userName">
  密码:<input type="password" v-model="password">
  <span v-if="error" style="background-color: red">账号密码错误</span>
  <button @click="login">登录</button>

</template>

<script setup>
import {useRouter} from "vue-router";
const router = useRouter()

const userName = $ref('')
const password = $ref('')

let error = $ref(false)

function login(){
  if('admin' == userName && '123456' == password){
    localStorage.setItem('loginToken','123456')
    router.push('/')
    error = false
  }else{
    error = true
  }
}

</script>

<style scoped>

</style>